#---------------------------------------------------
# VisualK-OS                                        
#    Module: Manual FBA Control Screen class [v1.0] 
#    Author: Kevin Slaughter                        
#---------------------------------------------------

"""
[Revision History]
    v1.0: Initial implementation... Having the screens encapsulated by
            the ScreenManager class with if-then-else blocks worked at
            first, when not much as required of the program, but more
            complex classes arose out of necessity to shrink/simplify
            the growing source code.
"""

import globals
from VKCC_Constants import *


class cScreenManualFBA(object):
    ### General properties
    color = 5                       # Color theme used within this screen
    title = "Manual Control - FBA"  # Title to be displayed
    hasExit = True                  # Flag: Display exit option
    
    
    ### handleKey(): Handle any passed keyboard input independent of GP usage.
    def handleKey(self, c, scr):
        # Function keys
        if (c == KEY_F1):
            scr.printText(3,14, "GOT KEY: F1  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_RED)
        elif (c == KEY_F2):
            scr.printText(3,14, "GOT KEY: F2  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_GREEN)
        elif (c == KEY_F3):
            scr.printText(3,14, "GOT KEY: F3  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_BLUE)
        elif (c == KEY_F4):
            scr.printText(3,14, "GOT KEY: F4  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_ORANGE)
        elif (c == KEY_F5):
            scr.printText(3,14, "GOT KEY: F5  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_CYAN)
        elif (c == KEY_F6):
            scr.printText(3,14, "GOT KEY: F6  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, VKC_PURPLE)
        elif (c == KEY_F7):
            scr.printText(3,14, "GOT KEY: F7  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_RED)
        elif (c == KEY_F8):
            scr.printText(3,14, "GOT KEY: F8  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_GREEN)
        elif (c == KEY_F9):
            scr.printText(3,14, "GOT KEY: F9  ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_BLUE)
        elif (c == KEY_F10):
            scr.printText(3,14, "GOT KEY: F10 ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_ORANGE)
        elif (c == KEY_F11):
            scr.printText(3,14, "GOT KEY: F11 ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_CYAN)
        elif (c == KEY_F12):
            scr.printText(3,14, "GOT KEY: F12 ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, VKC_PURPLE)
        elif (c == KEY_LBRACKET):
            scr.printText(3,14, "GOT KEY: [   ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, 0)
        elif (c == KEY_RBRACKET):
            scr.printText(3,14, "GOT KEY: ]   ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, 0)
        elif (c == KEY_Z):  # Turn all lights off
            scr.printText(3,14, "GOT KEY: Z   ", T_ERROR)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 0, 0)
            globals.CB.sendCmd("FBA", CMD_FLOOD, 1, 0)
            globals.CB.sendCmd("FBA", CMD_OFF, 0, 0)
        else: scr.printText(3,14, "GOT KEY: "+str(c)+"   ", T_ERROR)  # Display ASCII value
        
        # Exit key
        if (c == KEY_0): scr.changeScreen(SCREEN_MAIN)	# 0 = Back to main menu
        return
    
    
    ### paint(): Draw any elements used on this screen.
    def paint(self, scr):
        scr.menuPrep(self)
        
        # Board 0
        scr.printText(25,1, "[Board #0]", T_NORMAL,"s")
        scr.printText(25,2, " F1 : B0 - RED          ", T_NORMAL,"s")
        scr.printText(25,3, " F2 : B0 - GREEN        ", T_NORMAL,"s")
        scr.printText(25,4, " F3 : B0 - BLUE         ", T_NORMAL,"s")
        scr.printText(25,5, " F4 : B0 - ORANGE       ", T_NORMAL,"s")
        scr.printText(25,6, " F5 : B0 - CYAN (g/b)   ", T_NORMAL,"s")
        scr.printText(25,7, " F6 : B0 - PURPLE (r/b) ", T_NORMAL,"s")
        scr.printText(25,8, " [: B0 - White Floods   ", T_NORMAL,"s")
        
        # Board 1
        scr.printText(25,10, "[Board #1]", T_NORMAL,"s")
        scr.printText(25,11, " F7 : B1 - RED          ", T_NORMAL,"s")
        scr.printText(25,12, " F8 : B1 - GREEN        ", T_NORMAL,"s")
        scr.printText(25,13, " F9 : B1 - BLUE         ", T_NORMAL,"s")
        scr.printText(25,14, " F10: B1 - ORANGE       ", T_NORMAL,"s")
        scr.printText(25,15, " F11: B1 - CYAN (g/b)   ", T_NORMAL,"s")
        scr.printText(25,16, " F12: B1 - PURPLE (r/b) ", T_NORMAL,"s")
        scr.printText(25,17, " ]: B1 - White Floods   ", T_NORMAL,"s")
        
        # Dual/Special Functions
        scr.printText(2,4, "[Dual/Special]", T_NORMAL,"s")
        return
    